var isList="2"==document.all("unit.c").value;
var currentDomain=document.all("unit.domain").value;
//preview
function preview(){
	var publishMode=document.all("u.pp").value;
	var unitId=document.all("u.uid").value;
	var view=document.frames('unit.preview');
	if(unitId && publishMode=="0"){
		view.location='/dev/unit.preview.do?domain='+currentDomain+'&uid='+unitId;
	}else if(unitId){
		view.location='/'+currentDomain+'/'+unitId+'.do?m=e';
	}
}
//action
function xn(){
	xs.load();
	layout();
}
function xr(){
	xs.load();
	layout();
}
function xc(){
	xs.load();
	layout();
}
//find
function fr(){
	//var obj = $fTd(event.srcElement()).getElementsByTagName("INPUT")[0];
	//window.showModalDialog("/dev/resource.do",'',"dialogHeight: 300px; dialogWidth: 300px; dialogTop: 200px; dialogLeft: 650px; help: No;  resizable: No; status: No;");
	window.showModelessDialog("/dev/resource.do",'',"dialogHeight: 300px; dialogWidth: 300px; dialogTop: 200px; dialogLeft: 650px; help: No;  resizable: No; status: No;");
}
//menu
function onAutoLabelClick(){
	xs.setAddLabel();
	layout();
}
function onIsActionClick(){
	xs.setIsAction();
	re(xs);
}
function onAccessControlClick(){
	xs.setAuth();
	re(xs);
}
function onRemoveClick(){
	xs.remove();
	xs=null;
	layout();
}
function addTextFieldElement(){
	add('1');
}
function addUnitElement(){
	add('80');
}
var emenu=new Tree('em','m');
_bc.action= addTextFieldElement;
_ac.action= addUnitElement;
emenu.add(_bc);
emenu.add(_cc);
emenu.add(_ac);
emenu.add(_pc);
emenu.add(new MenuSeparator());
var em6=new Tree('em6','自动标签',onAutoLabelClick);
var em7=new Tree('em7','需要授权',onAccessControlClick);
var em8=new Tree('em8','Action',onIsActionClick);
if(!isList) emenu.add(em6);
emenu.add(em7);
emenu.add(em8);
emenu.add(new MenuSeparator());
emenu.add(_bx);
emenu.add(_cx);
emenu.add(_ax);
var em9=new Tree('em9','删除',onRemoveClick,deleteIcon.ENABLED);
emenu.add(new MenuSeparator());
emenu.add(em9);
function showMenu(){
	var c=emenu.writeMenu();
	if(!isList){
		if(xs && xa.shadow.area=="g" && xs.cs>0){
			setMenuSelected(c,em6,'',onAutoLabelClick,"0"!=xs.grid.all("e.al").value);
		}else{
			setMenuSelected(c,em6,MenuNaming.CSS_DISABLED,null,false);
		}
	}
	if(xs){
		setMenuSelected(c,em7,'',onAccessControlClick,"1"==xs.au);
		setMenuSelected(c,em8,'',onIsActionClick,"1"==xs.action);
		setMenuEnabled(c,em9,deleteIcon.ENABLED,onRemoveClick,true);
		setMenuEnabled(c,_bx,changeIcon.ENABLED,null,true);
		setMenuEnabled(c,_cx,changeIcon.ENABLED,null,true);
		setMenuEnabled(c,_ax,changeIcon.ENABLED,null,true);
	}else{
		setMenuSelected(c,em7,MenuNaming.CSS_DISABLED,null,false);
		setMenuSelected(c,em8,MenuNaming.CSS_DISABLED,null,false);
		setMenuEnabled(c,em9,deleteIcon.DISABLED,null,false);
		setMenuEnabled(c,_bx,changeIcon.DISABLED,null,false);
		setMenuEnabled(c,_cx,changeIcon.DISABLED,null,false);
		setMenuEnabled(c,_ax,changeIcon.DISABLED,null,false);
	}
}
//datamode
function setDataMode(mode){
	if(!mode) return ;
	var row = $fTr(document.all("u.d"));
	row.style.display=(mode=="1" || mode=="0")?"block":"none";
}
function getDataMode(){
	var objs=	document.all("u.dm");
	for(var i=0;i<objs.length;i++){
		if(objs[i].checked) return objs[i].value;
	}
	return null;
}
if(document.all("unit.c").value!="3"){setDataMode(getDataMode());}